package com.shenzhen.horselive.utils;

import android.os.Environment;

import java.io.FileOutputStream;
import java.io.IOException;

public class FileUtil {

    /**
     * 复制文件
     * @param filename 文件名
     * @param bytes 数据
     */
    public static void copy(String filename, byte[] bytes) {
        try {
            //如果手机已插入sd卡,且app具有读写sd卡的权限
            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                FileOutputStream output = null;
                output = new FileOutputStream(filename);
                output.write(bytes);
//                Log.i(TAG, copy: success，" + filename);
                output.close();
            } else {
//                Log.i(TAG, "copy:fail, " + filename);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
